package day018.homework.p5;

public class LuckDraw implements Runnable {
    private int num = 100;

    @Override
    public void run() {
        String threadName = Thread.currentThread().getName();
        int count = 0;
        while (true) {
            synchronized (this) {
                if (num <= 0) {
                    System.out.println("从" + threadName + "入场的员工总共：" + count + " 位员工");
                    break;
                } else {
                    String dc = DoubleColorBallutil.create();
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("编号为：" + num + " 的员工从" + threadName + "入场！"
                            + " 拿到的双色球彩票号码是：" + dc);
                    num--;
                    count++;
                }
            }
        }
    }
}
